package com.app.studyroom.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.app.studyroom.R;
import com.app.studyroom.db.UserInfo;

import java.util.List;

public class ContactAdminAdapter extends RecyclerView.Adapter<ContactAdminAdapter.ViewHolder> {

    private final List<UserInfo> adminList;

    public ContactAdminAdapter(List<UserInfo> adminList) {
        this.adminList = adminList;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvName, tvPhone, tvQy;

        public ViewHolder(View view) {
            super(view);
            tvName = view.findViewById(R.id.tvAdminName);
            tvPhone = view.findViewById(R.id.tvAdminPhone);
            tvQy = view.findViewById(R.id.tvAdminQy);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_contact_admin, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        UserInfo admin = adminList.get(position);
        holder.tvName.setText("管理员：" + admin.getUserName());
        holder.tvPhone.setText("电话：" + admin.getUserSjh());
        holder.tvQy.setText("管理区域：" + admin.getQy());
    }

    @Override
    public int getItemCount() {
        return adminList.size();
    }
}
